<template>
	<div class="fault-model">
		<div class="model-content">
			<!-- 头部主题 -->
			<div class="top-title">实时故障</div>
			<!-- 筛选展示部分 -->
			<div class="filter-show">
				<!-- 筛选部分 -->
				<div class="filter">
					<span class="filter-text">所属系统</span>
					<el-select v-model="value" @change="selectSystem">
						<el-option v-for="item in systemAll" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>
				</div>
				<!-- 数据显示部分 -->
				<div class="show">
					<div class="show-total">
						<span>总数: </span>
						<span class="total-text">{{tableData.length}}</span>
					</div>
				</div>
			</div>
			<uni-table border stripe emptyText="暂无更多数据" style="padding: 0 20px;margin-top: 20px;">
				<!-- 表头行 -->
				<uni-tr>
					<uni-th align="left">所属建筑</uni-th>
					<uni-th align="left">设备编号</uni-th>
					<uni-th align="left">设备类型</uni-th>
					<uni-th align="left">位置描述</uni-th>
					<uni-th align="left">报警原因</uni-th>
					<uni-th align="left">故障离线/时间</uni-th>
				</uni-tr>
				<!-- 表格数据行 -->
				<uni-tr v-for="item in tableData" :key="item.messageId">
					<uni-td>{{item.deptName}}</uni-td>
					<uni-td>{{item.code}}</uni-td>
					<uni-td>{{item.deviceTypeName}}</uni-td>
					<uni-td>{{item.addressDesc}}</uni-td>
					<uni-td>{{item.alarmReason}}</uni-td>
					<uni-td>{{item.alarmTime}}</uni-td>
				</uni-tr>

			</uni-table>
			<!-- 关闭按钮 -->
			<image src="../../static/img/close.png" mode="" class="close-png pointer" @tap="closeModel"></image>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				systemAll: [],
				tableData: [],
				currentSystem: '',
				value: ''
			}
		},
		created() {
			this.init()
			this.requestSystem()
		},
		methods: {
			init() {
				// this.requestSystem()
				this.requestFaultDevice()
			},
			// 请求九大系统
			async requestSystem() {
				let res = await this.$api.getAllSystem({

				})
				this.systemAll = res.data.map(v => {
					return {
						label: v.systemName,
						value: v.system
					}
				})
				this.systemAll = [{
					label: '全部系统',
					value: ''
				}].concat(this.systemAll)
			},
			closeModel() {
				//关闭故障弹窗
				this.$emit('closeFaultModel', false)
			},
			async requestFaultDevice() {
				let res = await this.$api.getDeviceFault({
					pageNum: 1,
					pageSize: 10,
					system: this.currentSystem,
					status: 0,
					confirm: 0
				})
				this.tableData = res.data.list
			},
			// 选择系统
			selectSystem(e) {
				this.currentSystem = e
				this.requestFaultDevice()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fault-model {
		width: 100vw;
		height: 100vh;
		background: rgba(0, 0, 0, 0.7);
		position: fixed;
		left: 0;
		top: 0;
		z-index: 1000;
		overflow-y: auto;
		.model-content {
			position: absolute;
			left: 50%;
			top: 5%;
			transform: translate(-50%, 0);
			width: 90%;
			height: 900px;
			background: #01192E;
			z-index: 3;

			//头部主题
			.top-title {
				margin-top: 28px;
				text-align: center;
				color: rgba(2, 195, 255, 1);
				font-size: 18px;
			}
			.top-title::after {
				content: '';
				display: block;
				position: absolute;
				width: 100%;
				top: 60px;
				opacity: 0.1;
				border: 1px solid #1ACFFF;
			}

			//筛选展示部分
			.filter-show {
				margin: 56px 0 0 20px;
				display: flex;

				.filter {
					.filter-text {
						color: #fff;
						margin-right: 10px;
					}

					.select {
						width: 220px;
						display: inline-block;
						flex: 0;
						height: 44px;

						.uni-select {
							border: 1px solid rgba(2, 195, 255, 1);
						}

					}

				}

				.show {
					margin-left: 30px;
					display: flex;
					color: #fff;
					align-items: center;
					font-size: 14px;

					div {
						margin-right: 40px;

						span {
							margin-right: 10px;
						}
					}

					.total-text {
						color: rgba(2, 195, 255, 1);
					}

					.fault-text {
						color: rgba(250, 147, 6, 1);
					}

					.offline-text {
						color: rgba(203, 206, 220, 1);
					}
				}

			}

			//关闭按钮
			.close-png {
				position: absolute;
				width: 17px;
				height: 19px;
				right: 20px;
				top: 19px;
			}
		}
	}
	.uni-table-td {
		color: rgba(255, 255, 255, 0.7);
		border-bottom: 1px solid rgba(2, 195, 255, 0.25);
		padding: 13px 10px;
	}
	.uni-table{
		.uni-table-tr{
			cursor: pointer;
			&:last-child{
				.uni-table-td{
					border-bottom: none;
				}
			}

		}
	}

	.uni-table-th {
		cursor: default;
		color: rgba(255, 255, 255, 1);
	}
	//取消表格空数据时取消右边框
	::v-deep .empty-border{
		border: none;
	}
</style>
